from picshell.ui.edit.JalEditor import JalEditor
from picshell.ui.Context import Context
import wx
class BrowserView:
    def __init__(self,parent,uiManager):
        # -------------------------------------------------------
        # lib Editor
        #
        self.mainSplitter = wx.SplitterWindow(parent, -1,style=wx.SP_NOBORDER)
        
        
        editorTreePanel = wx.Panel(self.mainSplitter, -1) 
        
        editorTreeSizer = wx.BoxSizer(wx.VERTICAL);
        editorTreePanel.SetSizer(editorTreeSizer)
        editorTree = wx.TreeCtrl(editorTreePanel, 1, wx.DefaultPosition, (-1,-1), wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS)
        editorTree.SetBackgroundColour("#ffffe1")
        editorTree.Bind(wx.EVT_TREE_SEL_CHANGED, uiManager.OnBrowserTreeSelChanged)
        editorTreeSizer.Add(editorTree,-1,wx.EXPAND)
        
        libPanel = wx.Panel(self.mainSplitter, -1)
        libSizer = wx.BoxSizer(wx.VERTICAL);
        libPanel.SetSizer(libSizer)
        editor = JalEditor(libPanel,-1)
        editor.uiManager = uiManager
        editor.parentTab = parent
        libSizer.Add(editor,-1,wx.EXPAND)
        self.mainSplitter.SplitVertically(libPanel,editorTreePanel)
        
        
        uiManager.browserEditor=editor
        uiManager.browserTree=editorTree
        uiManager.browserSplitter = self.mainSplitter
        self.mainSplitter.SetSashGravity(1)
         
        
    def getView(self):
        return  self.mainSplitter